package com.xyh.jdkproxy.Impl;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @Author:kyle
 * @Date:2020/12/11 - 10:30
 * @Project:spring_demo1
 * @Package:com.xyh.jdkproxy.Impl
 * @Version:1.0
 */
public class MyInvocationHandler implements InvocationHandler {
    private Object obj;//这是动态代理的好处，被封装的对象是Object类型，接受任意类型的对象

    public MyInvocationHandler(Object obj) {

        this.obj = obj;
    }

    public Object invoke(Object o, Method method, Object[] args) throws Throwable {

        System.out.println("jdk动态代理前");
        method.invoke(this.obj, args);
        System.out.println("jdk动态代理后");
        return null;
    }
}
